package cn.dubnation.base.util;

import cn.dubnation.base.enums.ResponseCode;
import lombok.Data;

@Data
public class AjaxResult {

    private Integer code;
    private Boolean success;
    private Object data;
    private String message;

    /**
     * 公共的静态方法,用来获取AjaxResult对象的
     * @return
     */
    public static AjaxResult me(){
        return new AjaxResult().setSuccess(true)
                               .setCode(ResponseCode.RESPONSE_CODE_200.getCode())
                               .setMessage(ResponseCode.RESPONSE_CODE_200.getMessage());
    }

    public Integer getCode() {
        return code;
    }

    public AjaxResult setCode(Integer code) {
        this.code = code;
        return this;
    }

    public Boolean getSuccess() {
        return success;
    }

    public AjaxResult setSuccess(Boolean success) {
        this.success = success;
        return this;    // this它的意思是:谁调用我我就是谁
    }

    public String getMessage() {
        return message;
    }

    public AjaxResult setMessage(String message) {
        this.message = message;
        return this;
    }

    public Object getData() {
        return data;
    }

    public AjaxResult setData(Object data) {
        this.data = data;
        return this;
    }
}
